<?php

namespace common\models\work;

use Yii;

/**
 * This is the model class for table "{{%survey}}".
 *
 * @property int $id
 * @property int $round_id 检测轮次ID
 * @property int $resident_id 居民身份ID
 * @property int $user_id 用户ID
 * @property string $result 扫码结果
 * @property string $char_set 字符集
 * @property string $scan_type 扫码类型
 * @property string $raw_data 加密串
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 * @property int $deleted_at 删除时间
 */
class Survey extends \common\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%survey}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['round_id', 'resident_id', 'user_id', 'status', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
            [['result', 'char_set', 'scan_type', 'raw_data'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'round_id' => '检测轮次ID',
            'resident_id' => '居民身份ID',
            'user_id' => '用户ID',
            'result' => '扫码结果',
            'char_set' => '字符集',
            'scan_type' => '扫码类型',
            'raw_data' => '加密串',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'deleted_at' => '删除时间',
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getResident() {
        return $this->hasOne(Resident::class, ['id' => 'resident_id']);
    }

}
